<template>
	<view :style="$store.state.skin">
		<view class="content">
			<view class="headTop">
				<view class="title">支付方式</view>
				<view class="payType">
					<image src="../../static/pay-icon/ck_cicon11.png" mode=""></image>
					<view>网银转账</view>
				</view>
			</view>

			<view class="headTop">
				<view class="payName">
					<view class="left">存款人姓名</view>
					<view class="right">
						<input type="text" v-model="name" placeholder="请输入存款人姓名" />
					</view>
				</view>
				<view class="payText">为及时到账，请务必输入正确存款人姓名</view>
			</view>

			<view class="headTop">
				<view class="title">存款金额</view>
				<view class="payNumBox">
					<view class="item" :class="{ itemz: value == item }" v-for="(item, index) in list" @click="itemClick(index)" :key="index">￥{{ item }}</view>
				</view>

				<view class="payInput">
					￥
					<input type="number" v-model="value" placeholder="请输入存款金额" />
					<text @click="value = ''" class="icon">×</text>
				</view>
			</view>

			<view class="btns" @click="submit">立即存款</view>
		</view>
	</view>
</template>

<script>
import request from '@/api/request.js';
export default {
	data() {
		return {
			name: '',
			value: '',
			payIndex: '',
			list: [1000, 2000, 3000, 5000, 10000, 50000]
		};
	},
	onShow() {
		// 设置导航栏颜色
		uni.setNavigationBarColor({
			frontColor: '#ffffff',
			backgroundColor: this.$store.state.presentColor
		});
	},
	methods: {
		itemClick(e) {
			this.payIndex = e;
			this.value = this.list[e];
		},
		submit() {
			if (!this.name) {
				uni.showToast({
					title: '请输入存款人姓名',
					icon: 'none'
				});
				return;
			}
			if (!this.value) {
				uni.showToast({
					title: '请输入存款金额',
					icon: 'none'
				});
				return;
			}

			request
				.post('/api/pay/recharge', {
					username: this.name,
					money: this.value
				})
				.then((res) => {
					if (res.code == '1') {
						uni.navigateTo({
							url: `/pages/wallet_money_info/wallet_money_info?money=${this.value}`
						});
					}
				});
		}
	}
};
</script>

<style lang="scss" scoped>
.content {
	min-height: 100vh;
	background-color: #f6f6f6;
}

.btns {
	width: 650rpx;
	margin: 20rpx auto;
	box-sizing: border-box;
	height: 80rpx;
	text-align: center;
	line-height: 80rpx;
	color: #fff;
	background-color: var(--nav-bg);
	justify-content: center;
	align-items: center;
	border-radius: 10rpx;
}
.payInput {
	margin-top: 30rpx;
	display: flex;
	align-items: center;
	input {
		flex: 1;
		margin: 0 20rpx;
	}
	.icon {
		width: 30rpx;
		display: flex;
		justify-content: center;
		// align-items: center;
		height: 30rpx;
		line-height: 30rpx;
		border: 1px solid #666;
		color: #666;
		border-radius: 30rpx;
	}
}
.payNumBox {
	margin-top: 40rpx;
	display: flex;
	justify-content: space-between;

	flex-wrap: wrap;
	.item {
		width: 180rpx;
		height: 80rpx;
		border: 1px solid #ccc;
		border-radius: 10rpx;
		display: flex;
		justify-content: center;
		align-items: center;
		margin-bottom: 30rpx;
	}
	.itemz {
		background-color: var(--mine-info);
		color: var(--nav-bg);
		border-color: var(--nav-bg);
	}
}

.payName {
	display: flex;
	padding-bottom: 20rpx;
	margin-bottom: 20rpx;
	border-bottom: 1px solid #f6f6f6;
	.left {
		margin-right: 30rpx;
	}
	.right {
		flex: 1;
	}
}
.payText {
	font-size: 24rpx;
	color: #999;
}

.headTop {
	padding: 20rpx;
	border-bottom: 10px;

	background-color: #fff;
	margin-bottom: 20rpx;
}
.payType {
	margin-top: 30rpx;
	width: 180rpx;
	height: 120rpx;
	display: flex;
	flex-direction: column;
	justify-content: center;
	align-items: center;
	font-size: 24rpx;
	border: 1px solid red;
	border-radius: 10rpx;
	image {
		width: 70rpx;
		height: 70rpx;
	}
}
</style>
